<?php
namespace services\models;

/**
 * Description of GoodsStock
 *
 * @author Administrator
 */
class GoodsStock extends \common\models\GoodsStock {
    public static function getDb() {
        return \Yii::$app->db;
    }

    /**
     * 通过商品ID获取商品库存信息
     * @param int $goods_id 商品ID
     * @return array 商品库存信息
     */
    public static function findByGoodsId($goods_id) {
        $var = self::find()->where('goods_id=:goods_id', [':goods_id' => $goods_id])->one();
        if(!$var) {
            return [];
        }
        return \yii\helpers\ArrayHelper::toArray($var);
    }
}
